#include "cimagewidget.h"
#include "ui_cimagewidget.h"

#include <QMouseEvent>

CimageWidget::CimageWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CimageWidget)
{
    ui->setupUi(this);
}

void CimageWidget::enterEvent(QEvent *)
{
    setStyleSheet("background-color:#474747;");
}

void CimageWidget::mousePressEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        mouse_press = true;
        emit btnClicked();
    }
}

void CimageWidget::mouseReleaseEvent(QMouseEvent *event)
{
    if(mouse_press&&this->rect().contains(event->pos()))
    {
        mouse_press = false;
        setStyleSheet("background-color:#474747;");
    }
}

void CimageWidget::leaveEvent(QEvent *)
{
    setStyleSheet("background-color: rgb(28, 30, 32);");
}

CimageWidget::~CimageWidget()
{
    delete ui;
}
